﻿Array.prototype.find = function (callback) {
    for (var i = 0; i < this.length; i++) {
        if (typeof (callback) == "function")
            callback(this[i], i, this);
    }
}
Array.prototype.each = function (callback) {
    for (var i = 0; i < this.length; i++) {
        if (typeof (callback) == "function")
            callback(this[i], i, this);
    }
}

CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
    if (w < 2 * r) r = w / 2;
    if (h < 2 * r) r = h / 2;
    this.moveTo(x + r, y);
    this.arcTo(x + w, y, x + w, y + h, r);
    this.arcTo(x + w, y + h, x, y + h, r);
    this.arcTo(x, y + h, x, y, r);
    this.arcTo(x, y, x + w, y, r);
    return this;
}